<template>
  <div>
    <!-- 关注 -->
    <div class="follow-user">
      <div class="user-item">
        <img src="https://img.zcool.cn/community/01e7da5d1d6f62a801207640428e93.jpg@1280w_1l_2o_100sh.jpg" alt="" />
        <p>雪王雪顶圣代</p>
      </div>
      <div class="user-item">
        <img src="https://ts1.cn.mm.bing.net/th/id/R-C.c92e4cebc74fda4aa69fcabd1d6f9510?rik=Nu5E%2bTbXloEs7g&riu=http%3a%2f%2fwww.gufengjia.com%2fd%2ffile%2fimages%2f201907011431%2f13-1FG1134102-50.jpg&ehk=%2fnCdmDwrZgDjNeyVQHMfYyfENYv2LGuMu5M0leqxZYc%3d&risl=&pid=ImgRaw&r=0" alt="" />
        <p>芋泥波波</p>
      </div>
      <div class="user-item">
        <img src="https://tse1-mm.cn.bing.net/th/id/OIP-C.Zxtf2X2EddV-g7hKyBhilAHaQB?rs=1&pid=ImgDetMain" alt="" />
        <p>芋圆葡萄</p>
      </div>
      <div class="user-item">
        <img src="https://ts1.cn.mm.bing.net/th/id/R-C.7d9f89acf7b699097bf4a4a2e286f8c4?rik=CiVM3rLj6NvVJg&riu=http%3a%2f%2fwww.gufengjia.com%2fd%2ffile%2fimages%2f201907011147%2f13-1PQ31P453-51.jpg&ehk=0hwAHGzwwIK6uyiMr5yM0VyWNK3%2bqBNjvqj1kTy5ZPM%3d&risl=&pid=ImgRaw&r=0" alt="" />
        <p>雪顶咖啡</p>
      </div>
    </div>

    <div class="follow-dynamic" v-for="(item) in dyState" :key="item._id">
      <div class="dynamic-user">
        <img :src="item.author?.img" alt="" />
        <span class="sp1">{{ item.author?.name }} · {{ item.pubTime.split('T')[0] }}</span>
        <span class="sp2"><van-icon name="ellipsis" /></span>
      </div>
      <img :src="item.imgPath" alt="" class="img1" />
      <div class="feature">
        <div class="feature-item" @click="changeUpvote(item._id,item.upvote,item.dzShow)">
          <img src="../../assets/like-active.png" alt="" v-if="item.dzShow"/>
          <img v-else src="../../assets/like.png" alt="" />
          <span :class="item.dzShow ? 'dz-active':''">{{ item.upvote }}</span>
        </div>
        <div class="feature-item"  @click="changeSC(item._id,item.collect,item.scShow)">
          <img src="../../assets/star-active.png" alt="" v-if="item.scShow"/>
          <img src="../../assets/star.png" alt="" v-else/>
          <span :class="item.scShow ? 'sc-active':''">{{ item.collect }}</span>
        </div>
        <div class="feature-item">
          <img src="../../assets/message.png" alt="" />
          <span>{{ item.reviewNum }}</span>
        </div>
      </div>
      <div class="dynamic-con">
        日常分享几张好看的图片！ 非常适合用来发朋友圈与动态，效果很棒
      </div>
      <div class="review">
        <p>白嫖党：感谢楼主，白嫖成功</p>
        <p>白嫖党：感谢楼主，白嫖成功</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import axios from '../../utils/axios'
import { onMounted, ref } from 'vue'
const dyState = ref([])
const getDyState = async()=>{
  let {data} = await axios.get('/dyStateList')
  console.log(data);
  dyState.value = data.data
}
const changeUpvote = async(id,upvote,dzShow)=>{
  let upv = dzShow ? upvote-1 : upvote+1
  await axios.put('/editState?id='+id,{upvote:upv,dzShow:!dzShow})
  getDyState()
}
const changeSC = async(id,collect,scShow)=>{
  let sc = scShow ? collect-1 : collect+1
  await axios.put('/editState?id='+id,{collect:sc,scShow:!scShow})
  getDyState()
}
onMounted(()=>{
  getDyState()
})
console.log(dyState.value,5555555)
</script>

<style scoped>
.follow-user {
  display: flex;
  justify-content: space-around;
}
.user-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
  justify-content: center;
}
.user-item img {
  width: 45px;
  height: 45px;
  border-radius: 25px;
  background-color: rgba(255, 255, 255, 1);
}
.user-item p {
  width: 85px;
  height: 20px;
  line-height: 20px;
  color: rgb(16, 16, 16);
  font-size: 14px;
  text-align: center;
  font-family: PingFangSC-regular;
}

.dynamic-user img {
  width: 50px;
  height: 50px;
  border-radius: 25px;
  background-color: rgba(255, 255, 255, 1);
  vertical-align: middle;
}
.dynamic-user .sp1 {
  margin-left: 11px;
  color: rgb(16, 16, 16);
  font-size: 14px;
  text-align: left;
  font-family: PingFangSC-regular;
  vertical-align: middle;
}
.dynamic-user .sp2 {
  margin-left: 70px;
  width: 30px;
  height: 30px;
}
.follow-dynamic .img1 {
  width: 275px;
  height: 300px;
  margin-left: 36px;
}
.follow-dynamic {
  padding: 0 20px;
  box-sizing: border-box;
  margin-top: 30px;
}
.feature {
  display: flex;
  margin-top: 10px;
}
.feature-item {
  margin-left: 15px;
}
.feature-item img {
  vertical-align: middle;
}
.feature-item span {
  margin-left: 10px;
  color: rgba(154, 154, 154, 1);
  font-size: 16px;
  text-align: left;
  font-family: PingFangSC-regular;
  vertical-align: middle;
}
.dynamic-con {
  width: 288px;
  height: 49px;
  line-height: 22px;
  color: rgb(16, 16, 16);
  font-size: 16px;
  text-align: left;
  font-family: PingFangSC-regular;
}
.review {
  width: 353px;
  height: 60px;
  line-height: 20px;
  border-radius: 15px;
  background-color: rgba(239, 239, 239, 1);
  color: rgba(16, 16, 16, 1);
  font-size: 14px;
  text-align: center;
  font-family: Roboto;
  padding: 12px;
  box-sizing: border-box;
}
.review p {
  width: 192px;
  height: 20px;
  line-height: 20px;
  color: rgb(16, 16, 16);
  font-size: 14px;
  text-align: left;
  font-family: PingFangSC-regular;
}
.dz-active{
  color: red;
}
.sc-active{
  color:#FFF81D
}
</style>
